﻿using System;
using System.Collections.Generic;
using System.Data;
using Microsoft.Reporting.WebForms;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace IMIS_ERP.Web.Order_Info
{
    public partial class Report_AreaSum_InstallDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["UCode"].ToString().Substring(5, 1) == "0")
                {
                    Response.Write("<script>alert('没有权限！');location.href='../ERP_Manager/EM_Page_Main.aspx';</script>");
                }
                Data_Bind("2010-1-1", "2110-1-1");
            }
        }

        private void Data_Bind(string strTime1, string strTime2)
        {
            string fiProvince = "", fiCity = "";
            if (Session["UType1"].ToString() == "0")
            {
                fiProvince = "%%";
                fiCity = "%%";
            }
            else if (Session["UType1"].ToString() == "1")
            {
                fiProvince = Session["UProvince"].ToString();
                fiCity = "%%";
            }
            else if (Session["UType1"].ToString() == "2")
            {
                fiProvince = Session["UProvince"].ToString();
                fiCity = Session["UCity"].ToString();
            }
            IMIS_ERP.BLL.Order_Products bll = new BLL.Order_Products();
            DataSet ds = bll.GetAresSum_InstallDetails(fiProvince, fiCity, strTime1, strTime2);
            ReportDataSource rds = new ReportDataSource("ds", ds.Tables[0]);
            this.RV.LocalReport.DataSources.Clear();
            this.RV.LocalReport.DataSources.Add(rds);
            this.RV.DataBind();
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string time1 = "2010-1-1", time2 = "2110-1-1", time3 = "2010-1-1", time4 = "2110-1-1"; ;
            if (txthTime1.Text != "")
            {
                time1 = txthTime1.Text.Trim() + " 00:00:00";
            }
            if (txthTime2.Text != "")
            {
                time2 = txthTime2.Text.Trim() + " 23:59:59";
            }
            Data_Bind(time1, time2);
        }
    }
}